home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bchelp10.zip / TI455.ASC < prev    next >
Text File  |  1991-09-11  |  3KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  TURBO C                                NUMBER  :  455
  9.   VERSION  :  2.0
  10.        OS  :  PC-DOS
  11.      DATE  :  OCTOBER 31, 1988                         PAGE  :  1/3
  12.  
  13.     TITLE  :  QUALIFYING VARIABLE NAMES
  14.  
  15.  
  16.  
  17.  
  18.   The  subsection "Qualifying Variable Names" on  page  57  of  the
  19.   Turbo  C  User's   Guide   is  inaccurate.    Use  the  following
  20.   information as documentation:
  21.  
  22.   There  are  three  typical situations in which it is desirable to
  23.   fully qualify a variable name used in an expression.
  24.  
  25.       o  To qualify a static  variable  in  another module, use the
  26.          following syntax:
  27.  
  28.               .<module name>.<variable name>
  29.  
  30.       o  To qualify a local variable  in a global function, use the
  31.          following syntax:
  32.  
  33.               <function name>.<variable name>
  34.  
  35.       o  To qualify a local variable  in a static function, use the
  36.          following syntax:
  37.  
  38.               .<module name>.<function name>.<variable name>
  39.  
  40.  
  41.  
  42.   The function name is  only  used when looking at a variable local
  43.   to the function.  For  example, suppose your program contains two
  44.   modules (FIRSTMOD, MYSUBS):
  45.  
  46.  
  47.   /* FIRSTMOD.C */
  48.   int a = 1;
  49.   main()
  50.   {
  51.        int b = 2;
  52.        myfunc();
  53.        printf("%d", i);
  54.   }
  55.  
  56.   /* MYSUBS.C */
  57.   static int e = 3;
  58.   static void localfunc(void)
  59.   {
  60.        int d = 4;
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  TURBO C                                NUMBER  :  455
  75.   VERSION  :  2.0
  76.        OS  :  PC-DOS
  77.      DATE  :  OCTOBER 31, 1988                         PAGE  :  2/3
  78.  
  79.     TITLE  :  QUALIFYING VARIABLE NAMES
  80.  
  81.  
  82.  
  83.  
  84.        printf("End of the road\n");
  85.   }
  86.   void myfunc(void)
  87.   {
  88.        int c = 5;
  89.        localfunc();
  90.   }
  91.  
  92.  
  93.   To watch the global variable a, use:
  94.  
  95.             a
  96.  
  97.   To watch the local variable b in main, use:
  98.  
  99.             main.b
  100.  
  101.   To watch the local variable c in myfunc, use:
  102.  
  103.             myfunc.c
  104.  
  105.   To watch the local variable d in the  static  function localfunc,
  106.   use:
  107.  
  108.             .mysubs.localfunc.d
  109.  
  110.   To watch the static variable e in module2, use:
  111.  
  112.             .mysubs.e
  113.  
  114.  
  115.   The  necessity  of  qualifiers  will   depend   on   the  current
  116.   instruction pointer.  For instance, if your program is running in
  117.   main, it is  unnecessary  to  qualify  the  variable  b  with the
  118.   function name main.  Likewise,  if your program is running inside
  119.   the  MYSUBS  module,  it is unnecessary to qualify the variable e
  120.   with the module name.
  121.  
  122.   Additionally, it is not  possible  to watch an auto (local) in an
  123.   inactive scope.  Since the function myfunc calls localfunc, it is
  124.   possible to watch the local variables of myfunc from localfunc --
  125.   the variables in myfunc are not removed when localfunc is called.
  126.   However, once myfunc returns to main, it is no longer possible to
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  TURBO C                                NUMBER  :  455
  141.   VERSION  :  2.0
  142.        OS  :  PC-DOS
  143.      DATE  :  OCTOBER 31, 1988                         PAGE  :  3/3
  144.  
  145.     TITLE  :  QUALIFYING VARIABLE NAMES
  146.  
  147.  
  148.  
  149.  
  150.   view its local variables  --  local  variables are discarded when
  151.   the function in which  they  are  located  returns to the calling
  152.   function.
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.